package com.founder.android;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.view.WindowManager;

public class MainActivity extends Activity {
	
	private static final int VIDEO_ACTIVITY_ID = 1;
	
	private static final int MENU_ACTIVITY_ID = 2;
	
	private static final int AD_ACTIVITY_ID = 3;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		//setContentView(R.layout.main);
		
		Intent intent = new Intent();
		intent.setClass(this, MoviePlayerActivity.class);
		intent.putExtra("dir", "video");				
		startActivityForResult(intent, VIDEO_ACTIVITY_ID);
	}
	
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		handler.sendEmptyMessageDelayed(requestCode, 1000);
	}
	
	private Handler handler = new Handler() {
		public void handleMessage(Message msg) {
			int requestCode = msg.what;
			//Log.e("MainActivity", "requestCode=" + requestCode);
			switch(requestCode) {
			case VIDEO_ACTIVITY_ID :
				Intent intent = new Intent() ;
				intent.setClass(MainActivity.this, MenuPlayActivity.class);
				intent.putExtra("dir", "menu");				
				startActivityForResult(intent, MENU_ACTIVITY_ID);
				break;
			case MENU_ACTIVITY_ID :
				intent = new Intent() ;
				intent.setClass(MainActivity.this, MoviePlayerActivity.class);
				intent.putExtra("dir", "ad");				
				startActivityForResult(intent, AD_ACTIVITY_ID);
				break;
			case AD_ACTIVITY_ID :
				intent = new Intent() ;
				intent.setClass(MainActivity.this, MoviePlayerActivity.class);
				intent.putExtra("dir", "video");				
				startActivityForResult(intent, VIDEO_ACTIVITY_ID);
				break;
			default:
				break;
			}
		}
	};
}